fix(kernel): Thrift parity fixes (TIMESTAMP range, DDL rows, User-Agent, VOID type)#416
Open
mani-mathur-arch wants to merge 5 commits into
Open
fix(kernel): Thrift parity fixes (TIMESTAMP range, DDL rows, User-Agent, VOID type)#416mani-mathur-arch wants to merge 5 commits into
mani-mathur-arch wants to merge 5 commits into
Conversation
The kernel Rows path converted arrow timestamps with arrow's ToTime, which forms an int64-nanosecond intermediate (value * unit-multiplier). For a microsecond TIMESTAMP — Databricks' wire unit — that overflows int64 outside ~1678-2262 and silently wraps a valid instant to a wrong one (TIMESTAMP '0001-01-01' scanned back as 1754-08-30, '9999-12-31' as 1816-03-30). Convert via the unit-specific time.Unix/UnixMilli/UnixMicro constructors, which split into (seconds, nanoseconds) internally and represent the full 0001-9999 range Databricks TIMESTAMP allows. The default Thrift path is unaffected — it receives TIMESTAMP as a preformatted server string and never runs this multiply — so this closes a kernel-only divergence from Thrift. TestScanCellTimestampOutOfNanoRange pins both repro endpoints plus the int64-ns boundary years; the existing unit and location tests still pass. Co-authored-by: Isaac Signed-off-by: Mani Kaustubh Mathur <mani.mathur@databricks.com>
The C ABI returns -1 for "not applicable / unknown" affected-row counts — DDL, SELECT, or a warehouse that doesn't surface the counter (the kernel's num_modified_rows Option<i64> None). The Thrift path reports 0 in those cases, so Result.RowsAffected() diverged: a CREATE/DROP SCHEMA returned -1 on the kernel backend and 0 on Thrift. Fold the -1 sentinel to 0 so RowsAffected() is identical across backends; a real DML count (>= 0) passes through unchanged. The rule lives in a pure, untagged normalizeAffectedRows so it is unit-testable in the default CGO_ENABLED=0 build alongside the other kernel decision helpers. Co-authored-by: Isaac Signed-off-by: Mani Kaustubh Mathur <mani.mathur@databricks.com>
mani-mathur-arch
force-pushed
the
mani/sea-kernel-comparator-fixes
branch
from
July 21, 2026 09:16
838bb0c to
21ad6fa
Compare
…iver The kernel backend never forwarded the driver's User-Agent, so the kernel's built-in UA leaked through and query history misattributed SEA-path queries. Forward the same composed UA the Thrift path sends via set_custom_header, so both backends are attributed alike. Default-on; WithUserAgentEntry still customizes it. Co-authored-by: Isaac Signed-off-by: Mani Kaustubh Mathur <mani.mathur@databricks.com>
The server stringifies VOID over the Thrift wire (verified live: even bare SELECT NULL reports STRING_TYPE), same as intervals, but hands the kernel a native arrow.NULL schema. Map arrow.NULL to STRING so both backends report identical column metadata; correct the two parity tests that wrongly pinned NULL_TYPE (derived from the enum name, never captured live). Co-authored-by: Isaac Signed-off-by: Mani Kaustubh Mathur <mani.mathur@databricks.com>
mani-mathur-arch
force-pushed
the
mani/sea-kernel-comparator-fixes
branch
from
July 22, 2026 18:51
db597fd to
8815db9
Compare
Address review of the parity fixes: assert kc.UserAgent == BuildUserAgent (non-empty) in TestBuildKernelConfig so deleting the forwarding or an empty UA fails a pure-Go run; add a CAST(NULL AS VOID) column to the live column-type parity query so the arrow.NULL→STRING mapping is guarded against the real server, not only the pure-Go tests. Trim the duplicated -1→0 rationale at the affected-rows call site to a one-liner. Co-authored-by: Isaac Signed-off-by: Mani Kaustubh Mathur <mani.mathur@databricks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Four SEA-via-kernel↔Thrift parity fixes surfaced by the Go comparator (two
database/sqlconnections against the same warehouse, differing only inuseKernel). All are kernel-path-only divergences from the default Thrift path; every fix is entirely Go-side (no kernel/C-ABI change).TIMESTAMP out-of-nanosecond-range wrapping. The kernel Rows path converted arrow timestamps with arrow's
ToTime, which forms anint64-nanosecond intermediate (value * unit-multiplier). For a microsecond TIMESTAMP — Databricks' wire unit — that overflowsint64outside ~1678–2262 and silently wraps a valid instant to a wrong one:TIMESTAMP '0001-01-01'scanned back as1754-08-30,'9999-12-31'as1816-03-30. Now converts via the unit-specifictime.Unix/UnixMilli/UnixMicroconstructors, which split into(seconds, nanoseconds)and represent the full 0001–9999 range. The default Thrift path is unaffected — it receives TIMESTAMP as a preformatted server string and never runs this multiply.DDL affected-rows reported as -1 instead of 0. The C ABI returns
-1for "not applicable / unknown" affected-row counts (DDL, SELECT, or a warehouse that doesn't surface the counter — the kernel'snum_modified_rowsOption<i64>None). The Thrift path reports0in those cases, soResult.RowsAffected()diverged: aCREATE/DROP SCHEMAreturned-1on the kernel backend vs0on Thrift. The-1sentinel is now folded to0; a real DML count (>= 0) passes through unchanged.User-Agent not forwarded on the kernel path. The kernel backend never forwarded the driver's composed User-Agent, so the kernel's built-in UA leaked through and query history misattributed SEA-path queries. Now forwards the same UA the Thrift path sends via
set_custom_header, so both backends are attributed alike. Default-on;WithUserAgentEntrystill customizes it.VOID/NULL columns reported as
NULLinstead ofSTRING. The kernel mapped anarrow.NULLcolumn toDatabaseTypeName="NULL"/nil scan type, but the server stringifies VOID over the Thrift wire — verified live, even a bareSELECT NULLreportsSTRING_TYPE, same as it does for intervals. Sosql.ColumnTypediverged between backends for any null/void column. Now mapsarrow.NULLtoSTRING(unbounded length, string scan type), matching Thrift. Also corrects two pure-Go parity tests that had pinnedNULL_TYPE— that expectation was derived from the enum name, not captured live, and the live server disagrees.Testing
TestScanCellTimestampOutOfNanoRange— pins both TIMESTAMP repro endpoints (0001-01-01,9999-12-31) plus theint64-ns boundary years; existing timestamp unit/location tests still pass.TestNormalizeAffectedRows— table test for the DDL sentinel-normalization rule, in a pure (untagged)normalizeAffectedRowsso it runs under the defaultCGO_ENABLED=0build.TestColumnTypeInfoFor/TestColumnTypeInfoMatchesThriftMapping/TestColumnTypeInfoScanTypeCoversScanner— the VOID→STRING mapping and its two cross-checks against the Thrift functions; all green.CGO_ENABLED=0) and tagged cgo (-tags databricks_kernel, linking the pinned kernel.a) — build + unit tests green on each.databricks-driver-testGo comparator, Thrift vs SEA over 108 cases): this PR takes the run from 41 → 14 diffs vs drivermain. The TIMESTAMP-range and VOID cases are fully resolved and DDL is down to a lone residual; the remaining 14 are pre-existing and unrelated to this PR (comparator NaN-vs-NaN artifacts, engine-specific EXPLAIN text, a permission-gated CREATE PROCEDURE, kernel feature gaps in arrow-batch fetch / volume staging, and an empty-result-set metadata gap that is a separate kernel-side follow-up).Stacked on
mani/sea-kernel-new-items(#412).Co-authored-by: Isaac